package ru.paswd.demo.android.view.components

import kotlin.math.sqrt

class DiscriminantSqEquResolver : SqEquResolver {
    override fun resolve(a: Double, b: Double, c: Double): List<Double> {
        val d = (b * b) - (4 * a * c)
        return when {
            d > 0.0 -> listOf(
                ((-b) + sqrt(d)) / (2 * a),
                ((-b) - sqrt(d)) / (2 * a),
            )
            d == 0.0 -> listOf((-b) / (2 * a))
            else -> emptyList()
        }
    }
}